package com.have.blog.xo.service.admin.impl;

import com.have.blog.base.enums.BlogStatus;
import com.have.blog.utils.ResultUtils;
import com.have.blog.xo.constant.SysConstant;
import com.have.blog.xo.service.*;
import com.have.blog.xo.service.admin.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;

@Service
public class AdminIndexServiceImpl implements AdminIndexService {
    @Autowired
    private AdminBlogService blogService;
    @Autowired
    private AdminCommentService commentService;
    @Autowired
    private AdminUserService userService;
    @Autowired
    private AdminWebVisitService webVisitService;

    @Override
    public String init() {
        HashMap<String, Object> map = new HashMap<>();
        // 获取可见博客数量
        map.put(SysConstant.BLOG_COUNT, blogService.getBlogCount(BlogStatus.ENABLE.getStatus()));
        // 获取可见评论数量
        map.put(SysConstant.COMMENT_COUNT, commentService.getCommentCount(BlogStatus.ENABLE.getStatus()));
        // 获取用户数量
        map.put(SysConstant.USER_COUNT, userService.getUserCount(BlogStatus.ENABLE.getStatus()));
        // 获取浏览量
        map.put(SysConstant.VISIT_COUNT, webVisitService.getWebVisitCount());
        return ResultUtils.result(SysConstant.SUCCESS, map);
    }
}
